package com.demo.algorithm;

import org.junit.Test;

public class 整数反转 {

	public int reverse(int x) {
		long ans = 0;
		while (x != 0) {
			ans = ans * 10 + x % 10;
			x = x / 10;
		}
		return (int) ans == ans ? (int) ans : 0;
	}

	@Test
	public void testReverse() {
		int reverse = reverse(0);
		System.out.println(reverse);
	}
}
